<?php
    include_once '../service/Project_Service.php';
    include_once '../service/Gallery_Service.php';

    $project        =   new Project_Service();
    $service_Gallery        =   new Gallery_Service();
    $cate_id = $_GET['cate_id'];
    $table      =   "";
    $check = 0;
//    $limit      =   15;
//    $show_page  =   10;
//    $page       =   (isset($_GET['page']))? $_GET['page'] : 1;
//    $offset = ($page - 1) * $limit;
//    $rows = $Project->getRows();
//    foreach ($rows as $value){
//            $totalRows = $value;
//    }
//    $totalPages = ceil($totalRows/$limit);
    $list_Project   =   $project->getList_Project($cate_id);
    foreach ($list_Project as $value){
        $pro_id     = $value->getID();
        $id[]       = $pro_id;
        $name[]       = $value->getPro_Name();
        $image[]    = $service_Gallery->getFirst_Gallery($pro_id);
        $descript[] =  $value->getPro_Description();
        $check=1;
    }
?>
<h2 style="float: left">List of project</h2>
<a class="button_add" href="index.php?action=ip&cate_id=<?php echo $cate_id; ?>" alt="">
    <i class="add"></i>
    <span class="uiButtonText">Add project</span>
</a>
<div class="clear-block" style="margin-top: 10px;">
            <div class="node-form">
                <div class="standard">

                    <?php
                        if($check == 1)
                        {


                            $i = 0;
                            $count_id = count($id);
                            while($i < $count_id)
                            {
                               $image_new = ($image[$i] != '')?$image[$i]:'no_photo.jpg';
                                $table .='<div class="list-image">
                                            <div class="pro_image">
                                                <a href="index.php?action=mg&pro_id='.$id[$i].'"><img style="width:75px;height:75px;" alt="" src="../uploads/thumb/'.$image_new.'"/></a>
                                            </div>
                                            <a href="index.php?action=up&id='.$id[$i].'" class="icon_edit"></a>
                                                <div class="project_info">
                                                    <p class="project_title_name">Project Name :</p>
                                                    <p class="project_content_name">'.$name[$i].'</p>
                                                    <p class="project_title_des">Description&nbsp;&nbsp;&nbsp;&nbsp;:</p>
                                                    <div class="project_content_des">'.$descript[$i].'</div>
                                                </div>
                                            <a href="../action/control_project.php?action=delete&cate_id='.$cate_id.'&id='.$id[$i].'" class="icon_del" onclick="return confirm(\'Really delete?\');"></a>
                                            <div class="ii"></div>
                                        </div>';
                                ++$i;
                            }
                        }
                         else {
                            $table = "don't have any project!!!";
                        }
                        echo $table;
                    ?>

                </div>
            </div>
</div>